package cn.com.tomato.service;

import java.util.List;

import cn.com.tomato.controller.domain.todoSet.SortVo;
import cn.com.tomato.mapper.FocusMapper;
import cn.com.tomato.mapper.TodoMapper;
import cn.com.tomato.mapper.TodoSetMapper;
import cn.com.tomato.model.ToDo;
import cn.com.tomato.model.TodoSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-08-16
 */
@Service
public class TodoSetService
{
    @Autowired
    private TodoSetMapper todoSetMapper;

    @Autowired
    private TodoMapper todoMapper;

    @Autowired
    private FocusMapper focusMapper;

    public TodoSet selectTodoSetById(Long id)
    {
        return todoSetMapper.selectById(id);
    }

    public List<TodoSet> selectTodoSetList(TodoSet todoSet)
    {
        return todoSetMapper.selectList(todoSet);
    }

    public int insertTodoSet(TodoSet todoSet)
    {
        // 设置默认值,设置为未完成
        todoSet.setFinish(0);
        todoSet.setSetSort(todoSetMapper.getMaxSort() + 1);
        return todoSetMapper.insert(todoSet);
    }

    public int updateTTodoSet(TodoSet todoSet)
    {
        return todoSetMapper.update(todoSet);
    }

    public int deleteTodoSetByIds(Long[] ids)
    {
        return todoSetMapper.deleteTTodoSetByIds(ids);
    }

    public int deleteTodoSetById(Long id)
    {
        focusMapper.deleteByToDoSet(id);
        todoMapper.deleteByToDoSet(id);
        return todoSetMapper.deleteById(id);
    }

    public void updateSort(List<SortVo> sortVos){
        todoSetMapper.updateSort(sortVos);
    }
}